<?php

// Define base Monkake application directory
$dirname = dirname(__FILE__);

// Main Monkake Model file
require_once($dirname . '/Monkake.php');

$m = new Monkake();

// Get page controller name
$page_name = str_replace('/doc-root', '', @$_SERVER['PATH_INFO']);

// Main Monkake configuration file
require_once($dirname . '/config.php');

$handlers_view = $m->GetIntercept($page_name);

if ( $handlers_view == NULL ) $handlers_view = $m->Get('site_404_controller');

// TODO: Run more validation on the controller name?
if ( !$handlers_view ) $m->Error('Could not locate 404 controller', TRUE);

$handler = $m->GetHandler($handlers_view['handlers'], $m, $handlers_view['view']);

